/**
 * Created by 追风少年 on 2018/6/9.
 */

var ServiceProviderInput = {
    URL:{
        FIND_ONE_URL:"/admin/serviceProvider/findById"
    }
};
app.controller('serviceProviderInfoController', function($scope,$http) {

    $scope.flowTypeList = [];
    $scope.entity = {};

    // 页面加载完成
    $scope.load = function(){
        var id = $("#serviceId").val();
        $http.post(ServiceProviderInput.URL.FIND_ONE_URL,{id:id}).success(function(data,status,headers,config){
            if(data.status){
                $scope.entity = data.data;
                $scope.initValue();
            }else{
                console.error(data);
                alert("数据加载失败,请联系管理员");
            }
        }).error(function(data,status,headers,config){
            console.error(data);
        });
    };

    // 转换类型为显示的值
    $scope.initValue = function(){
        if($scope.entity.service_type=="1"){
            $scope.entity.service_type = "正式";
        }else if($scope.entity.service_type=="2"){
            $scope.entity.service_type = "临时";
        }
        if($scope.entity.service_status=="1"){
            $scope.entity.service_status = "正常";
        }else if($scope.entity.service_status=="0"){
            $scope.entity.service_status = "禁用";
        }
        if($scope.entity.account_type=="1"){
            $scope.entity.account_type = "个人";
        }else if($scope.entity.account_type=="2"){
            $scope.entity.account_type = "企业";
        }
    };

});